/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package codegener.entity;

import codegener.util.StrUtils;

/**
 * 数据源配置实体
 * @author 32181
 */
public class DsBean {
    
    private String title;
    private String type;
    private String url;
    private String host;
    private String port;
    private String dbname;
    private String uname;
    private String upass;
    private boolean selected;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    
    public String getUrl() {
        switch(type){
            case "MySQL":{
                this.url="jdbc:mysql://"+host+":"+port+"/"+dbname+"?useSSL=false";
            }break;
            case "Oracle":{
                this.url="jdbc:oracle:thin:@"+host+":"+port+":"+dbname;
            }break;
            case "达梦":{
                this.url="jdbc:dm://"+host+":"+port;
            }break;
        }
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public String getUpass() {
        return upass;
    }

    public void setUpass(String upass) {
        this.upass = upass;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public String getDbname() {
        return dbname;
    }

    public void setDbname(String dbname) {
        this.dbname = dbname;
    }
    
    public boolean isValid(){
        if(StrUtils.isNotBlank(type)&&StrUtils.isNotBlank(url)&&StrUtils.isNotBlank(uname)&&StrUtils.isNotBlank(upass)){
            return true;
        }
        return false;
    }
    
}
